package edu.chen.enums;

/**
 * 租借状态的枚举类
 */

public enum LeaseStateEnum implements BasicEnum{
    SUCCESS(1, "租借成功"), NO_NUMBER(0, "库存不足"),NO_BOOK(-1,"书本不存在"),REPEAT_LEASE(-2,"重复借阅"), INNER_ERROR(-3, "系统异常");


    private int state;
    private String stateInfo;

    LeaseStateEnum(int state, String stateInfo) {
        this.state = state;
        this.stateInfo = stateInfo;
    }

    public int getState() {
        return state;
    }

    public String getStateInfo() {
        return stateInfo;
    }

    public static LeaseStateEnum stateOf(int index){
        for (LeaseStateEnum stateEnum : values()){
            if(stateEnum.getState()  == index)
                return stateEnum;
        }
        return null;
    }

}
